@echo off
chcp 65001 >nul
echo 🚀 启动后端服务...
echo 📍 项目地址: http://localhost:8080/api
echo ===============================

cd /d "%~dp0"
echo 📂 当前目录: %CD%

echo 🧼 检查Java版本...
java -version
if %errorlevel% neq 0 (
    echo ❌ Java未正确安装或配置
    pause
    exit /b 1
)

echo 🧹 清理项目...
call mvn clean
if %errorlevel% neq 0 (
    echo ❌ Maven clean 失败
    pause
    exit /b 1
)

echo ===============================
echo 🚀 启动Spring Boot应用...
echo 💡 如果看到 "Started ServerMigrationApplication" 说明启动成功
echo ===============================
call mvn spring-boot:run

if %errorlevel% neq 0 (
    echo ❌ 应用启动失败
    echo 💡 可能的原因:
    echo    - 端口8080被占用
    echo    - 数据库连接问题
    echo    - 配置文件错误
    pause
)

pause